package com.hopu.v1.controller.front.exam;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopu.v1.pojo.common.R;
import com.hopu.v1.pojo.exam.ExamGrades;
import com.hopu.v1.pojo.exam.ExamStudentRecords;
import com.hopu.v1.service.front.exam.EStudentRecordsService;
import com.hopu.v1.utils.JwtUtils;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: EStudentRecordsController
 * Description:
 *
 * @Author lh
 * @Create 2024/10/8 19:57
 * @Version 1.0
 */
@RestController
@RequestMapping("/examStudent")
public class EStudentRecordsController {
    @Autowired
    private EStudentRecordsService eStudentRecordsService;

    @GetMapping("/getOne")
    public R selectList(Integer examId,HttpServletRequest request) {
        String token = request.getHeader("frontToken");
        String studentId = JwtUtils.getUserId(token);
        System.out.println("studentId"+studentId);

        LambdaQueryWrapper<ExamStudentRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ExamStudentRecords::getStudentId, studentId);
        wrapper.eq(ExamStudentRecords::getExamRecordId, examId);
        return R.ok(eStudentRecordsService.getOne(wrapper));
    }
}
